﻿<Window x:Class="UITest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:ui="clr-namespace:DMC.UI;assembly=DMC.UI"
        xmlns:auth="clr-namespace:DMC.Auth;assembly=DMC.Auth"
        xmlns:uiauth="clr-namespace:DMC.UI.Auth;assembly=DMC.UI"
        xmlns:this="clr-namespace:UITest"
        Title="DMC.UI Test" Height="500" Width="900" Loaded="Window_Loaded">
    <Window.Resources>
        <this:SimotionViewModel x:Key="vm"/>
        <ui:BusyToVisibilityConverter x:Key="busyToVisibilityConverter" />
        <this:SeverityToImageConverter x:Key="severityToImageConverter" />
        
    </Window.Resources>
    <Grid DataContext="{Binding Source={StaticResource vm}}">
        <DockPanel>
            
            <Menu DockPanel.Dock="Top">
                <MenuItem Name="File" Header="File">
                    <MenuItem Name="Login" Header="Login" Click="Login_Click" />
                    <MenuItem Name="Progress" Header="Progress" Click="Progress_Click" />
                    <Separator />
                    <MenuItem Name="Exit" Header="Exit" Click="Exit_Click" />
                </MenuItem>
                <MenuItem Name="Edit" Header="Edit">
                
                </MenuItem>
                <MenuItem Header="Help">
                    <MenuItem Name="About" Header="About" Click="About_Click" />
                </MenuItem>
            </Menu>
            

            <!--<StatusBar DockPanel.Dock="Bottom">
                <StatusBarItem>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="User: " />
                        <TextBlock DataContext="{x:Static Member=auth:UserAdminMgr.Manager}" Text="{Binding Path=AuthenticatedUser.Name}"  />
                    </StackPanel>
                </StatusBarItem>
                <Separator />
                <StatusBarItem />
            </StatusBar>-->
        
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="0" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="50" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <!--<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal">
                    <Image Source="/UITest;component/Siemens%20Logo.png"></Image>
                    <TextBlock>Simotion Project Sync Tool</TextBlock>
                </StackPanel>-->
                
                <DockPanel Grid.Row="1" Grid.Column="0">
                    <Grid DockPanel.Dock="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" VerticalAlignment="Center" FontSize="18" FontWeight="Bold" Margin="5,0">Project List:</TextBlock>
                        <UniformGrid Grid.Column="1" Rows="1" Columns="2">
                            <Button Command="{Binding Path=SelectAllCmd}" Margin="5,5">Select All</Button>
                            <Button Command="{Binding Path=SelectNoneCmd}" Margin="5,5">Select None</Button>
                        </UniformGrid>
                    </Grid>
                    
                    <ListView ItemsSource="{Binding Projects}" Margin="5">
                        <ListView.View>
                            <GridView>
                                
                                <GridView.Columns>
                                    <GridViewColumn>
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <CheckBox IsChecked="{Binding Path=IsSelected}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn>
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Name}" VerticalAlignment="Center" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView.Columns>
                            </GridView>
                        </ListView.View>
                    </ListView>
                </DockPanel>
                <UniformGrid Grid.Row="2" Grid.Column="0" Rows="1" Columns="3">
                    <Button Margin="10" Content="Update All"/>
                    <Button Margin="10" Content="Update Selected"/>
                    <Button Margin="10" Content="Update Master"/>
                </UniformGrid>
                <DockPanel Grid.Row="1" Grid.Column="1" Grid.RowSpan="2">
                    <TextBlock DockPanel.Dock="Top" VerticalAlignment="Center" FontSize="18" FontWeight="Bold" Margin="5,0">Log:</TextBlock>
                    <ListView ItemsSource="{Binding LogEvents}" Margin="5">
                        <ListView.Resources>
                            <Style TargetType="ListViewItem">
                                <Setter Property="IsEnabled" Value="False"/>
                            </Style>
                        </ListView.Resources>
                        <ListView.View>
                            <GridView>
                                <GridView.Columns>
                                    <GridViewColumn Width="30">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <Image Height="16" Width="16" Source="{Binding Path=LogSeverity, Converter={StaticResource severityToImageConverter}}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn>
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Timestamp}" VerticalAlignment="Center" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn>
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Message}" VerticalAlignment="Center" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView.Columns>
                            </GridView>
                        </ListView.View>
                    </ListView>
                </DockPanel>
            </Grid>
        </DockPanel>

        <!--<ui:ProgressPanel Name="ProgressPanel" Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ui:DMCWindow}, Path=IsBusy, Converter={StaticResource busyToVisibilityConverter}}" MouseDown="ProgressPanel_MouseDown" />-->
        
    </Grid>
</Window>
